<?php
session_start();
if(session_id()==''){
	session_id($_POST['PHPSESSID']);
}
function Bic()
{
    list($usec, $sec) = explode(" ", microtime());
	$usec=$usec+(rand(1,400)*rand(400,900)*rand(900,1300));
	$sec=$sec+(rand(1,400)*rand(400,900)*rand(900,1300));
    return 100*(((float)$usec + (float)$sec));
}
//echo $_SESSION['fileupFs']['path'];exit(0);
	// The Demos don't save files
	if (isset($_FILES[$_SESSION['fileupFs']['name']]) && is_uploaded_file($_FILES[$_SESSION['fileupFs']['name']]["tmp_name"]) && $_FILES[$_SESSION['fileupFs']['name']]["error"] == 0) {
		$path=$_SESSION['fileupFs']['path']==''?"../../uploads/pic/":$_SESSION['fileupFs']['path'];
		$otype=substr(strtolower($_FILES[$_SESSION['fileupFs']['name']]["name"]),-3);
		$tImgName=Bic();
		$tempname=$_POST['oldname']==''?'zh'.$tImgName.".".$otype:$_POST['oldname'];
		$filename=$path.$tempname;
		if($_POST['oldname']!=''){
			@unlink($filename);
		}
		$copymes=move_uploaded_file($_FILES[$_SESSION['fileupFs']['name']]["tmp_name"],$filename);

		echo $tempname;
		//echo rand(1000000, 9999999);	// Create a pretend file id, this might have come from a database.
	}

	exit(0);	// If there was an error we don't return anything and the webpage will have to deal with it.
?>